
import 'package:flutter/material.dart';
import 'package:flutterlib/common/constants/constants.dart';
import 'package:flutterlib/common/net/dao_result.dart';
import 'package:flutterlib/common/net/retrofit/post_api.dart';
import 'package:flutterlib/common/utils/navigator_utils.dart';
import 'package:flutterlib/common/utils/toast.dart';
import 'package:flutterlib/model/post/post_bean.dart';
import 'package:flutterlib/widgets/bussiness/post/card_list_item.dart';
import 'package:flutterlib/widgets/bussiness/post/post_list_item.dart';
import 'package:flutterlib/widgets/bussiness/post/post_list_item_admin.dart';

import '../post_list_widget_page.dart';

class PostNormalListWidgetPage extends PostListWidgetPage {
  final String name;
  final int type;

  PostNormalListWidgetPage({this.name, this.type, Key key})
      : super(key: key);

  @override
  PostNormalListWidgetPageState createState() => PostNormalListWidgetPageState();
}

///页面 KeepAlive ，同时支持 动画Ticker
class PostNormalListWidgetPageState extends PostListWidgetPageState<PostNormalListWidgetPage>
    {

  getDataLogic(int page) async {
    print(page);
    if(widget.type == 0){
      var posts = await PostApi.builder().pageBySheet(
          page - 1, 20, "createTime,desc", currentUserId, 0, "PUBLISHED");
      return new DataResult(posts.content, true);
    }
    if(widget.type == 1){
      var posts = await PostApi.builder().pageBySheet(
          page - 1, 20, "createTime,desc", currentUserId, 0, "DRAFT");
      return new DataResult(posts.content, true);
    }
    if(widget.type == 2){
      var posts = await PostApi.builder().pageBySheet(
          page - 1, 20, "createTime,desc", currentUserId, 0, "RECYCLE");
      return new DataResult(posts.content, true);
    }
  }

  Widget renderItem(index, post) {
    //提交
    return CardListItem(post, onPressed: () {
      // NavigatorUtils.goPostDetail(context, post.id);
    });
  }

  @override
  List<Widget> renderHeader(BuildContext context, bool innerBoxIsScrolled) {
    List<Widget> widgets = [];

    return widgets;
  }

}
